import java.util.Arrays;

public class MyStack {
    public int[] elem;
    public int usedSize;

    public MyStack(){
        this.elem = new int[2];
    }

    public void push(int val){
        if(isFull()){
            this.elem = Arrays.copyOf(elem, elem.length * 2);
        }
        elem[usedSize] = val;
        usedSize++;
    }
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        int ret = elem[usedSize - 1];
        usedSize--;
        return ret;
    }

    public int peel(){
        if(isEmpty()){
            return -1;
        }
        return elem[usedSize - 1];
    }

    public boolean isEmpty(){
        return usedSize == 0;
    }

    public boolean isFull(){
        return usedSize == elem.length;
    }

}
